﻿using RockBus.Logging.Interfaces;
using RockBus.Messages.Interfaces;
using RockBus.Routing.Interfaces;
using System;
using System.Reflection;

namespace RockBus.Routing.SendPorts
{
    public class InMemoryErrorProcessor : IMessageProcessor
    {
        public InMemoryErrorProcessor(ILogger logger)
        {
            this.Logger = logger;
        }

        public MessageProcessorEnum ProcessingStep { get { return MessageProcessorEnum.ErrorManager; } }

        public void ProcessMessage(IMessageContext messageContext)
        {
            this.Logger.LogError(MethodBase.GetCurrentMethod(), "ERROR for {0}:{1}{2}", messageContext, Environment.NewLine, messageContext.Exception);
            messageContext.Abort();
        }

        public ILogger Logger { get; set; }
    }
}